home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / tsfaqp34.zip / FAQPAS4.TXT < prev    next >
Internet Message Format  |  1996-09-14  |  51KB

  1. From ts@uwasa.fi Sat Sep 14 00:00:00 1996
  2. Subject: FAQPAS4.TXT contents
  3.  
  4.                                Copyright (c) 1993-1996 by Timo Salmi
  5.                                                  All rights reserved
  6.  
  7. FAQPAS4.TXT The fourth set of frequently (and not so frequently)
  8. asked Turbo Pascal questions with Timo's answers. The items are in
  9. no particular order.
  10.  
  11. You are free to quote brief passages from this file provided you
  12. clearly indicate the source with a proper acknowledgment.
  13.  
  14. Comments and corrections are solicited. But if you wish to have
  15. individual Turbo Pascal consultation, please post your questions to
  16. a suitable Usenet newsgroup like news:comp.lang.pascal.borland. It
  17. is much more efficient than asking me by email. I'd like to help,
  18. but I am very pressed for time. I prefer to pick the questions I
  19. answer from the Usenet news. Thus I can answer publicly at one go if
  20. I happen to have an answer. Besides, newsgroups have a number of
  21. readers who might know a better or an alternative answer. Don't be
  22. discouraged, though, if you get a reply like this from me. I am
  23. always glad to hear from fellow Turbo Pascal users.
  24.  
  25. ....................................................................
  26. Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
  27. Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
  28. Department of Accounting and Business Finance  ; University of Vaasa
  29. ts@uwasa.fi http://uwasa.fi/~ts BBS 961-3170972; FIN-65101,  Finland
  30.  
  31. --------------------------------------------------------------------
  32. 76) What are the current Pascal newsgroups on the Usenet news?
  33. 77) How do I detect the CapsLock status, how do I turn it on/off?
  34. 78) How do I detect if the F11 or F12 key has been pressed?
  35. 79) How do I extract (parse) substrings from an input string?
  36. 80) How do I find out the size of any kind of a file?
  37. 81) How do I format graphics output like in textmode writeln?
  38. 82) How do I detect if more than one standard key is pressed down?
  39. 83) How can I read a disk's Volume Serial Number?
  40. 84) How can I disable and then enable the keyboard in my TP program?
  41. 85) How do I get the character device name of the (first) CD-ROM?
  42. 86) How do I eject a CD-ROM using a Turbo Pascal program?
  43. 87) How do I find out if the ANSI.SYS driver has been loaded?
  44. 88) Where do I find Turbo Pascal tutorials and/or good textbooks?
  45. 89) How do I make an executable of my Turbo Pascal source program?
  46. 90) How can I quickly read the last byte of a file?
  47. 91) Is 2000 a leap year? What is the leap year algorithm?
  48. 92) Does anybody have a program that gives the week number?
  49. 93) How can I use OutText to write numbers in the graphics mode?
  50. 94) How can I redirect output to file if I use the Crt unit?
  51. 95) How to write a function to return true if I am in graphics mode?
  52. 96) My graph.tpu got corrupted. Someone please email me a new copy.
  53. 97) How can I avoid run-time errors in numeric input using readln?
  54. 98) How can I limit the user's readln input to e.g. 3 characters?
  55. 99) Can you tell a beginner how to delete files with Turbo Pascal?
  56. 100) Could you please explain shl and shr operators to a beginner?
  57. --------------------------------------------------------------------
  58.  
  59. From ts@uwasa.fi Sat Sep 14 00:01:16 1996
  60. Subject: Usenet Pascal newsgroups
  61.  
  62. 76. *****
  63.  
  64.  Q: What are the current Pascal newsgroups on the Usenet news?
  65.  
  66.  A: The following new Pascal newsgroups were created June 12, 1995
  67. to replace the old comp.lang.pascal. The new Delphi newsgroups were
  68. first created around July 10, 1995. Further Delphi newsgroups were
  69. added in April 1996.
  70.  
  71. A special note about Delphi postings. Please use the delphi
  72. newsgroups for the Delphi related postings. In particular, the
  73. newsgroup comp.lang.pascal.borland is _NOT_ for Delphi related
  74. subjects!
  75.  
  76. A second special note. Please avoid crossposting between the
  77. newsgroups. In particular do not crosspost between the old and the
  78. new newsgroups. It slows the transition to the new system. (This
  79. automatic posting breaches the general non-crossposting tenet only
  80. because it is relevant information about the arrangements of all the
  81. newsgroups involved.)
  82.  
  83. CURRENT:
  84.  comp.lang.pascal.ansi-iso Pascal according to ANSI and ISO standards.
  85.  comp.lang.pascal.borland  Borland's Pascal incl. Turbo Pascal (not Delphi!)
  86.  comp.lang.pascal.mac      Macintosh based Pascals.
  87.  comp.lang.pascal.misc     Pascal in general and ungrouped Pascals.
  88.  
  89.  comp.lang.pascal.delphi.advocacy Contentious issues related to Delphi.
  90.  comp.lang.pascal.delphi.announce Delphi related announcements. (Moderated)
  91.  comp.lang.pascal.delphi.components.misc General component issues.
  92.  comp.lang.pascal.delphi.components.usage Using pre-written components.
  93.  comp.lang.pascal.delphi.components.writing Writing Delphi components.
  94.  comp.lang.pascal.delphi.databases Database aspects of Borland Delphi.
  95.  comp.lang.pascal.delphi.misc General issues with Borland Delphi.
  96.  comp.sources.delphi Delphi and ObjectPascal source code. (Moderated)
  97.  
  98. RELATED of potential interest:
  99. comp.os.msdos.programmer.turbovision Borland's text application libraries
  100.  
  101. OLD:  Please cease using!
  102.  comp.lang.pascal                     Discussion about Pascal.
  103.  comp.lang.pascal.delphi.components   Writing components in Borland Delphi.
  104.  
  105. For more information about the Pascal newsgroups please see
  106.  
  107.  52703 Jun 14 1995 ftp://garbo.uwasa.fi/pc/doc-net/pasgroup.zip
  108.  pasgroup.zip Information about the comp.lang.pascal.* newsgroups
  109.  
  110. If your site is not getting the new Pascal newsgroups, please
  111. contact your own site's newsmaster about the situation.
  112. --------------------------------------------------------------------
  113.  
  114. From ts@uwasa.fi Sat Sep 14 00:01:17 1996
  115. Subject: Capslock status and toggling
  116.  
  117. 77. *****
  118.  Q: How do I detect the CapsLock status, how do I turn it on/off?
  119.  
  120.  A: Here are the relevant Turbo Pascal routines in answer to these
  121. questions.
  122.   {}
  123.   Uses Dos;  { The Dos unit is needed }
  124.   {}
  125.   (* Is CapsLock on *)
  126.   function CAPSONFN : boolean;
  127.   var regs      : registers;
  128.       KeyStatus : byte;
  129.   begin
  130.     FillChar (regs, SizeOf(regs), 0);
  131.     regs.ax := $0200;      { Get shift flags }
  132.     Intr ($16, regs);      { The keyboard interrupt }
  133.     KeyStatus := regs.al;  { AL = shift status bits }
  134.     if (KeyStatus and $40) > 0 then         { bit 6 }
  135.       capsonfn := true
  136.     else
  137.       capsonfn := false;
  138.   end;  (* capsonfn *)
  139.   {}
  140.   (* Set CapsLock. Use true to turn on, false to turn off *)
  141.   procedure CAPS (TurnOn : boolean);
  142.   var keyboardStatus : byte absolute $0040:$0017;
  143.       regs           : registers;
  144.   begin
  145.     if TurnOn then
  146.        keyboardStatus := keyboardStatus or $40
  147.      else
  148.        keyboardStatus := keyboardStatus and $BF;
  149.     { Interrrupt "check for keystroke" to ensure the LED status }
  150.     FillChar (regs, SizeOf(regs), 0);
  151.     regs.ah := $01;
  152.     Intr ($16, regs);
  153.   end;  (* caps *)
  154.   {}
  155. As you see, CapsLock is indicated by bit 6. The other toggles can be
  156. handled in an equivalent way using this information about the memory
  157. location Mem[$0040:$0017]:
  158.   ScrollLock = bit 4      $10  $EF
  159.   NumLock    = bit 5      $20  $DF
  160.   CapsLock   = bit 6      $40  $BF
  161. --------------------------------------------------------------------
  162.  
  163. From ts@uwasa.fi Sat Sep 14 00:01:18 1996
  164. Subject: Detecting F11 and F12
  165.  
  166. 78. *****
  167.  Q: How do I detect if the F11 or F12 key has been pressed?
  168.  
  169.  A: Here is a sample program
  170.   uses Dos;
  171.   (* Enhanced keyboard ReadKey, no Crt unit needed. Detects also F11
  172.      and F12, and distinguishes between the numeric keypad and the
  173.      gray keys. Lower part of the word returns the first scan code,
  174.      the higher part the second *)
  175.   function RDENKEFN : word;
  176.   var regs     : registers;
  177.       keyboard : byte absolute $40:$96;
  178.   begin
  179.     rdenkefn := 0;
  180.     if ((keyboard shr 4) and 1) = 0 then exit;
  181.     FillChar (regs, SizeOf(regs), 0);
  182.     regs.ah := $10;
  183.     Intr ($16, regs);
  184.     rdenkefn := regs.ax;
  185.   end;  (* rdenkefn *)
  186.   {}
  187.   procedure TEST;
  188.   var key : word;
  189.   begin
  190.     while Lo(key) <> 27 do  { esc exits }
  191.       begin
  192.